package models
type SystemQuestionLevel struct {
	Id           int `json:"id" xorm:"not null pk autoincr comment('主键') INT(11)"`
	QuestionId int `json:"question_id" xorm:"not null comment('题目主键') INT(11)"`
	LevelId int `json:"level_id" xorm:"not null comment('阶段主键')  INT(11)"`
}
var systemquestionlevel ="system_question_level"

func(q *SystemQuestionLevel) GetRow() bool {
	has, err := mEngine.Get(q)
	if err==nil &&  has  {
		return true
	}
	return false
}

//通过questionId,查询对应的knowledgeId
func(q *SystemQuestionLevel) GetByQuestionId(questionId int ) ([]int,error){
	var levelIds []int
	err:=mEngine.Table(systemquestionlevel).Cols("level_id").
		Where("question_id =?  " ,questionId).Find(&levelIds)


	return levelIds, err


}
func(q *SystemQuestionLevel) DeleteByQuestionId(questionId int ) error{
	//no commitment
	_,err:=mEngine.Table(systemquestionlevel).Where("question_id =?  " ,questionId).Delete(q)

	return  err

}


